﻿// -----------------------------------------------------------------------
// <copyright file="MainFormDataGridRow.cs" company="Microsoft">
//    Apple might sue me
// </copyright>
// -----------------------------------------------------------------------

namespace Eeeek
{
    using System;
    using System.ComponentModel;
    using System.Drawing;

    /// <summary>
    /// Holds properties for display in the main data grid
    /// </summary>
    [Serializable]
    public class MainFormDataGridRow : INotifyPropertyChanged
    {
        #region Fields

        /// <summary>
        /// Backing store for the Action property
        /// </summary>
        private MouseAction action;

        /// <summary>
        /// Backing store for the X property
        /// </summary>
        private int locationX;

        /// <summary>
        /// Backing store for the Y property
        /// </summary>
        private int locationY;

        /// <summary>
        /// Backing store for the delay
        /// </summary>
        private int delayInMilliseconds;

        #endregion

        /// <summary>
        /// Initializes a new instance of the <see cref="MainFormDataGridRow"/> class.
        /// </summary>
        // ReSharper disable MemberCanBePrivate.Global (Is required for serialization)
        public MainFormDataGridRow()
        // ReSharper restore MemberCanBePrivate.Global
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="MainFormDataGridRow"/> class.
        /// </summary>
        /// <param name="action">The action.</param>
        /// <param name="point">The point.</param>
        /// <param name="delay">The delay.</param>
        public MainFormDataGridRow(MouseAction action, Point point, int delay)
        {
            this.action = action;
            this.locationX = point.X;
            this.locationY = point.Y;
            this.delayInMilliseconds = delay;
        }

        /// <summary>
        /// Occurs when a property value changes.
        /// </summary>
        public event PropertyChangedEventHandler PropertyChanged;

        /// <summary>
        /// Gets or sets the action.
        /// </summary>
        /// <value>
        /// The action.
        /// </value>
        public MouseAction Action
        {
            get
            {
                return this.action;
            }

            // ReSharper disable UnusedMember.Global (Is required for serialization)
            set
            // ReSharper restore UnusedMember.Global
            {
                this.action = value;
                this.NotifyPropertyChanged("Action");
            }
        }

        /// <summary>
        /// Gets or sets the location X.
        /// </summary>
        /// <value>
        /// The location X.
        /// </value>
        public int LocationX
        {
            get
            {
                return this.locationX;
            }

            // ReSharper disable UnusedMember.Global (Is required for serialization)
            set
            // ReSharper restore UnusedMember.Global
            {
                this.locationX = value;
                this.NotifyPropertyChanged("LocationX");
            }
        }

        /// <summary>
        /// Gets or sets the location Y.
        /// </summary>
        /// <value>
        /// The location Y.
        /// </value>
        public int LocationY
        {
            get
            {
                return this.locationY;
            }

            // ReSharper disable UnusedMember.Global (Is required for serialization)
            set
            // ReSharper restore UnusedMember.Global
            {
                this.locationY = value;
                this.NotifyPropertyChanged("LocationY");
            }
        }

        /// <summary>
        /// Gets or sets the delay in milliseconds.
        /// </summary>
        /// <value>
        /// The delay in milliseconds.
        /// </value>
        public int DelayInMilliseconds
        {
            get
            {
                return this.delayInMilliseconds;
            }

            // ReSharper disable UnusedMember.Global (Is required for serialization)
            set
            // ReSharper restore UnusedMember.Global 
            {
                this.delayInMilliseconds = value;
                this.NotifyPropertyChanged("DelayInMilliseconds");
            }
        }

        /// <summary>
        /// Notifies the property changed.
        /// </summary>
        /// <param name="name">The name.</param>
        private void NotifyPropertyChanged(string name)
        {
            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(name));
            }
        }
    }
}
